/**
 * 告警
 */
import request from '@/utils/request';

// 自定义告警列表数据查询
export function queryCustomAlarmList(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/customAlarm',
		method: 'post',
		data: query,
	});
}

// 基础告警列表数据查询
export function queryBaseAlarmList(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/baseAlarm',
		method: 'post',
		data: query,
	});
}

// 根据id查询告警(基础、自定义)
export function queryAlarmById(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/' + id,
		method: 'get',
	});
}

// 根据系统id和端的类型id查询端的信息
export function querySegmemtByTypeAndSystemId(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/api/modules/segment/querySegmemtByTypeAndSystemId',
		method: 'post',
		data: query,
	});
}

// 新增告警
export function addAlarm(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/baseAlarm/save',
		method: 'post',
		data: query,
	});
}

// 修改告警
export function editAlarm(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/baseAlarm',
		method: 'put',
		data: query,
		// noSliceEmpty: true,
	});
}

// 批量删除告警
export function deleteAlarmByIds(ids: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/delete/' + ids,
		method: 'delete',
	});
}

// 修改告警是否启用
export function editAlarmEnable(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/customAlarm/editAlarmEnable',
		method: 'post',
		data: query,
	});
}

// ===============添加该方法是为了区分权限控制，因为若多个页面或多个按钮调用的是同一个方法，那他们的权限也会被捆绑在一起================

// 新增自定义告警
export function addCustomAlarm(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/customAlarm/save',
		method: 'post',
		data: query,
	});
}

// 修改告警
export function editCustomAlarm(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarm/customAlarm',
		method: 'put',
		data: query,
	});
}
